package cn.wolfcode.luowowo.article.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import cn.wolfcode.luowowo.common.util.DateToWeek;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;

@Setter
@Getter
public class AirTicketQuery extends QueryObject {

    private String departCityName;  //出发城市
    private String destCityName; //到达城市
    private String airlines;  //航空公司
    private String aircraftModels;  //机型
    private String departureTime;   //出发时间
    private String departureAirport;    //出发机场
    private String landingAirport;    //到达机场

    private String startDate;  //出发日期
    private int price; //价格
    private int titalPrice;  //总价格

    private String week;  //航班星期几

    private String sTime;  //条件筛选开始时间
    private String eTime;  //条件筛选结束时间
    private String aircrewName;

    private int is_sun=-1;
    private int is_mon=-1;
    private int is_tue=-1;
    private int is_wed=-1;
    private int is_thr=-1;
    private int is_fri=-1;
    private int is_sat=-1;

    //日期转换为星期
    public String getWeek() {

        return DateToWeek.dateToWeek(startDate);
    }

    //筛选的时间转换
    public String getsTime() {
        if(departureTime!="-1"&&departureTime!=null) {
            String[] split = departureTime.split("-");
            String strsTime = split[0];
            return strsTime;

        }
        return null;
    }

    public String geteTime() {
        if(departureTime!="-1"&&departureTime!=null) {
            String[] split = departureTime.split("-");
            String strsTime = split[1];

            return strsTime;
        }
        return null;
    }

    //判断星期
    public int getIs_sun() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期天")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_mon() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期一")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_tue() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期二")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_wed() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期三")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_thr() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期四")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_fri() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期五")) {
                return 1;
            }
        }
        return -1;
    }

    public int getIs_sat() {
        if (getWeek()!=null) {
            if ((this.getWeek()).equals("星期六")) {
                return 1;
            }
        }
        return -1;
    }

    public int getTitalPrice() {
        int i = this.price + 30;
        return i;
    }
}


